package com.platform.core.entity;

import com.platform.enums.FunctionStatus;
import com.platform.enums.FunctionType;
import com.platform.enums.converters.FunctionStatusConverter;
import com.platform.enums.converters.FunctionTypeConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * Description: 菜单信息实体类
 *
 * @author libin Created on 2019/7/18
 **/
@EqualsAndHashCode(of = {"id"})
@Data
@Entity
@Table(name = "ncloud_sys_function")
public class SysFunction implements Serializable {

    private static final long serialVersionUID = 1993274520754559419L;

    @Id
    @Column(name = "id", length = 36)
    @Getter
    @Setter
    private String id;

    /**
     * 菜单名称
     */
    @Column(name = "function_name", length = 200, nullable = false)
    private String name;

    /**
     * 分系统编号
     */
    @Column(name = "sub_system_code", length = 255, nullable = false)
    private String subSystemCode;

    @Column(name = "sub_system_id", length = 32, nullable = false)
    private String subSystemId;

    /**
     * 上级菜单
     */
    @Column(name = "function_parent", length = 36)
    private String parentId;

    /**
     * 菜单级别
     */
    @Column(name = "function_level")
    private Integer level;

    /**
     * 排序编号
     */
    @Column(name = "function_sort")
    private Integer sortNum;

    /**
     * 菜单资源url
     */
    @Column(name = "function_url", length = 500)
    private String url;

    /**
     * 菜单前端路由
     */
    @Column(name = "function_path", length = 500)
    private String path;


    /**
     * 信息状态
     */
    @Column(name = "delflag")
    @Convert(converter = FunctionStatusConverter.class)
    private FunctionStatus delFlag;

    /**
     * 菜单类型
     */
    @Column(name = "function_type", length = 16)
    @Convert(converter = FunctionTypeConverter.class)
    private FunctionType type;


    /**
     * 业务类型,扩展用
     */
    @Column(name = "biz_type", length = 16)
    private String bizType;

    /**
     * 菜单路由
     */
    @Column(name = "route_code", length = 2048)
    private String route;

    /**
     * 所属管理域
     */
    @Column(name = "manage_domain", length = 36)
    private String domain;

    /**
     * 菜单描述
     */
    @Column(name = "function_desc", length = 36)
    private String desc;

    /**
     * 菜单图标
     */
    @Column(name = "function_icon", length = 64)
    private String icon;

    /**
     * 创建时间
     */
    @Getter
    @Setter
    @CreatedDate
    @Column(name = "create_date", nullable = false, updatable = false)
    private LocalDateTime createDate;


    /**
     * 修改时间
     */
    @Getter
    @Setter
    @LastModifiedDate
    @Column(name = "update_date")
    private LocalDateTime updateDate;

    @Column(name = "link_type", length = 30)
    private String linkType;

}
